package updater.currency.data;

import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.text.SimpleDateFormat;
import java.util.ArrayList;
import java.util.Date;
import java.util.Random;

import com.thoughtworks.xstream.XStream;
import com.thoughtworks.xstream.io.xml.DomDriver;

import updater.currency.convertor.ReadRSS;
/*
public class DataGenerator {

	public static String GetFullNameBySymbol(String symbol) {
		ReadRSS readRSS = new ReadRSS();
		ArrayList<CurrencyName> currencyNameList = readRSS
				.GetCurrencyNameList("currency_list");

		for (int i = 0; i < currencyNameList.size(); i++) {
			if (currencyNameList.get(i).getSymbol().equals(symbol)) {
				return currencyNameList.get(i).getName();
			}
		}

		return "Invalid";

	}

	public static void GenerateDataBySymbol(String symbol, Date startDate,
			int numOfRecord, double min_price, double max_price) {
		XStream xstream = new XStream(new DomDriver());
		ArrayList<Currency> currencyList = new ArrayList<Currency>();
		for (int i = 0; i < numOfRecord; i++) {
			Currency currency = new Currency();
			String filePath = "Data/" + symbol + ".xml";
			String currentPath = new File(filePath).getAbsolutePath();
			String from = GetFullNameBySymbol(symbol);

			startDate.setDate(startDate.getDate() + 1);
			SimpleDateFormat sdf = new SimpleDateFormat(
					"EEE, dd MMM yyyy HH:mm:ss z");
			String date = sdf.format(startDate);
			Random r = new Random();
			double randomPrice = min_price + (max_price - min_price)
					* r.nextDouble();
			java.text.DecimalFormat df = new java.text.DecimalFormat("#.00000");
			String randomPriceStr = df.format(randomPrice);

			currency.setCurrency(from, symbol, date, randomPriceStr);
			currencyList.add(currency);
			try {
				FileOutputStream fs = new FileOutputStream(currentPath);
				xstream.toXML(currencyList, fs);
			} catch (FileNotFoundException e1) {
				e1.printStackTrace();
			}

		}
	}
}*/
